/*************/
#include <stdio.h>
#include <conio.h>
#include <iostream>
using namespace std;

void out(char *s);

class Stack{
	int MAX;
	int realSize;
	int *p;

public:

	Stack(){
		MAX = 100;
		realSize = 0;
		p = new int[MAX];
	};
	Stack(int max){
		MAX = max;
		realSize = 0;
		p = new int[MAX];
	}
	void push(int n){
		if(realSize < MAX){
			p[realSize] = n;
			realSize++;
		}
		else
		{
			out("Stack full, not add more");
		}
	}
	int pop(){
		if (realSize >0)
		{
			realSize -- ;
			return p[realSize];
		}
		else
		{
			out("Stack empty!");
			return -1;
		}
	}
	int isEmpty(){
		if (realSize >0)
		{
			return 0;
		}
		return 1;
	}
	int top(){
		if (realSize >0)
		{
			return p[realSize -1];
		}
		return -1;
	}
};
void toBinary(int n){
	Stack st;
	while (n > 0)
	{
		st.push(n%2);
		n = n/2;
	}
	while (!st.isEmpty())
	{
		cout<<st.pop();

	}
}
void out(char *mes){
	cout << "\nMESSAGE: ";
	cout<<mes;
}
void main(){

	int max = 0;
	//out("Nhap max: ");
	//cin >> max;
	//Stack st(max);
	/*while (1)
	{
		int t;
		out("Nhap ptu: ");
		cin >> t;
		if(t==-1) break;
		st.push(t);
	}
	while (1)
	{
		char c;
		out("Ban muon pop ko? y/n: ");
		c = getch();
		if(c== 'y' || c== 'Y') {
			cout<<"\npop result: "<<st.pop();
		}

	}*/
	int n = 123;
	toBinary(n);
	getch();
}

/********************/
